<template>
  <div>
    <basic-container>
      <el-breadcrumb separator="/">
        <el-breadcrumb-item>数据</el-breadcrumb-item>
        <el-breadcrumb-item>用户</el-breadcrumb-item>
        <el-breadcrumb-item>Plus会员用户购买数据</el-breadcrumb-item>
      </el-breadcrumb>
    </basic-container>
    <basic-container>
      <avue-crud
        ref="crud"
        :data="data"
        v-model="form"
        :option="option"
        :page.sync="page"
        @on-load="getList"
        @refresh-change="refreshChange"
        @search-reset="from = {}"
        @search-change="searchChange"
      >
      </avue-crud>
    </basic-container>
  </div>
</template>

<script>
import { handleExcelCat } from "@/api/exportCommon";
import { common } from "@/api/cat/httpRequest";
import { appStatisticsMemberBuy as baseUrl } from "@/api/cat/baseUrls";
export default {
  data() {
    return {
      page: {
        total: 0,
        pageSize: 10,
      },
      defalut: {
        vip_type: 1,
      },
      type: true,
      data: [],
      params: {},
      form: {},
      option: {
        addBtn: false,
        editBtn: false,
        viewBtn: false,
        delBtn: false,
        excelBtn: false,
        selection: true,
        border: true,
        menu: false,
        index: true,
        indexLabel: "序号",
        column: [
          {
            label: "日期",
            prop: "stats_date",
            type: "input",
          },
          {
            label: "会员用户总数",
            type: "input",
            prop: "member_total",
          },
          {
            label: "月卡会员数",
            prop: "month_card_member_num",
            type: "input",
          },
          {
            label: "季卡会员数",
            prop: "season_card_member_num",
            type: "input",
          },
          {
            label: "年卡会员数",
            prop: "year_card_member_num",
            type: "input",
          },
          {
            label: "新增会员数",
            prop: "add_member_num",
            type: "input",
          },
          {
            label: "购买月卡数",
            prop: "month_card_buy_num",
            type: "input",
          },
          {
            label: "购买季卡数",
            prop: "season_card_buy_num",
            type: "input",
          },
          {
            label: "购买年卡数",
            prop: "year_card_bug_num",
            type: "input",
          },
          {
            label: "复购月卡率",
            prop: "month_card_repeat_buy_rate",
            type: "input",
          },
          {
            label: "复购季卡率",
            prop: "season_card_repeat_buy_rate",
            type: "input",
          },
          {
            label: "复购年卡率",
            prop: "year_card_repeat_buy_rate",
            type: "input",
          },
          {
            label: "选择日期",
            type: "daterange",
            prop: "daterange",
            hide: true,
            search: true,
          },
        ],
      },
    };
  },
  methods: {
    /**获取列表 */
    async getList() {
      this.loading = true;
      //清空表格列表
      this.data = [];
      this.params.orderByList = "stats_date&DESC";
      //发送请求获取数据
      let response = await common(
        `${baseUrl.pageAndParam}`,
        { ...this.params, ...this.defalut },
        this.page,
        "POST"
      );

      this.page = response.page;
      this.data = response.data;
      this.loading = false;
    },
    /**刷新 */
    refreshChange() {
      this.getList();
    },
    /**搜索 */
    searchChange(params, done) {
      params.stats_date = `${
        params.daterange ? "!<>!" + params.daterange : ""
      }`;
      this.params = params;
      this.page.currentPage = 1;
      delete params.daterange;
      this.getList();
      if (done) {
        done();
      }
    },
  },
};
</script>